﻿using System;
using MailClient.Data;
using MailClient;

namespace MailClient.Handlers
{
    /// <summary>
    /// Enumeration for the various primary commands
    /// </summary>
    enum Command { None = 0, Request, Approval, Help, Info, List, Stop, Contacts, Subscribe, Unsubscribe, Training };

    /// <summary>
    /// Flag for the approval command
    /// </summary>
    enum designator { Add = 1, Remove };

    /// <summary>
    /// Parses emails for command handling
    /// </summary>
    public delegate void CommandCompleteHandler(EventArgs e);

    /// <summary>
    /// Process incoming mail for off handing to command handling, sorting, scrubbing, etc.
    /// </summary>
    class incoming
    {
        #region Private
        private Job job;
        private System.Net.Mail.MailMessage reply = new System.Net.Mail.MailMessage();

        #endregion


        public event CommandCompleteHandler CommandComplete;


        #region CTOR
        public incoming(MailMessage msg)
        {
            job = new Job(msg);

        }
        #endregion



        #region procedures

        public MailMessage Process()
        {
            Commands.ICommand c = job.GetCommand;
            //IContact[] ct = _msg.FromContacts;
            if (c != null)

                if (c.Command(job))
                {
                    return c.MsgReply;
                    CommandComplete(EventArgs.Empty);
                }

            return null;

        }





        #endregion
    }

}
